// $codepro.audit.disable packageNamingConvention

/** Packages */
package edu.gatech.team404;

import java.util.ArrayList;
import java.util.List;

/**
 * An information holder for a course.
 * @author Michael Dandy
 * @version 1.0
 */
public class Course {
	/** The name of the course */
	private String name;
	
	/** The description of the course */
	private String description;
	
	/** The username of the instructor */
	private String instructor;
	
	/** Labs associated with this course */
	private List<Lab> labs;

	/**
	 * Constructor
	 * @param name the name of the course
	 * @param instructorUsername the username of the course's instructor
	 */
	public Course(String name, String instructorUsername) {
		this (name, "", instructorUsername);
	}

	/**
	 * Constructor
	 * @param name the name of the course
	 * @param description the description of the course
	 * @param instructorUsername the username of the course's instructor
	 */
	public Course(String name, String description, String instructorUsername) {
		this.name = name;
		this.description = description;
		this.instructor = instructorUsername;
		this.labs = new ArrayList<Lab>();
	}
	
	/**
	 * Add a lab to this course
	 * @param lab the lab to be added
	 * @return true on success or false otherwise
	 */
	public boolean addLab (Lab lab) {
		return labs.add(lab);
	}
	
	/**
	 * Remove a lab from this course
	 * @param labId the lab ID to be removed
	 * @return true on success or false otherwise
	 */
	public boolean removeLab (String labId) {
		for (Lab lab : labs) {
			if (lab.getId().equalsIgnoreCase(labId)) {
				return labs.remove(lab);
			}
		}
		return false;
	}
	
	/**
	 * Check if the specified lab is associated with this course or not.
	 * @param labID the ID of the lab
	 * @return true if lab exists or false otherwise
	 */
	public boolean isLabExist (String labId) {
		for (Lab lab : labs) {
			if (lab.getId().equalsIgnoreCase(labId)) {
				return true;
			}
		}
		return false;
	}
	
	/**
	 * Get a lab associated with this course with the specified lab ID.
	 * @param labID the ID of the lab
	 * @return the lab with the specified lab ID
	 */
	public Lab getLab (String labId) {
		for (Lab lab : labs) {
			if (lab.getId().equalsIgnoreCase(labId)) {
				return lab;
			}
		}
		return null;
	}
	
	/**
	 * Get all the labs associated with this course.
	 * @return all the labs associated with this course
	 */
	public List<Lab> getAllLabs () {
		return labs;
	}

	/**
	 * Get the name of the course.
	 * @return the name of the course
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set the name of the course.
	 * @param name the name of the course
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Get the description of the course.
	 * @return the description of the course
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Set the description of the course.
	 * @param description the description of the course
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Get the username of the course's instructor.
	 * @return the username of the course's instructor
	 */
	public String getInstructor() {
		return instructor;
	}

	/**
	 * Set the username of the course's instructor.
	 * @param instructorUsername he username of the course's instructor
	 */
	public void setInstructor(String instructorUsername) {
		this.instructor = instructorUsername;
	}

	/**
	 * Print the attributes of this course.
	 * @return the attributes of this course
	 */
	@Override
	public String toString() {
		return "Course [name=" + name + ", description=" + description
				+ ", instructor=" + instructor + ", labs=" + labs + "]";
	}
	
	
}
